<template>
  <view>
    <view class="">
      <view class="from">
        <view style="padding: 26rpx 32rpx">
          <view class="title">
            <text>房屋图片</text>
            <text style="color: #999999; font-size: 26rpx; font-weight: 400"
              >({{ fileList ? fileList.length : 0 }}/6)
            </text>
          </view>
          <view class="upload-group dis-flex flex-y-between">
            <u-upload
              width="200rpx"
              height="200rpx"
              :custom-btn="true"
              max-count="6"
              :action="action"
              :auto-upload="true"
              :file-list="fileList"
              :before-upload="beforeUpload"
              @on-remove="onRemove"
            >
              <view
                slot="addBtn"
                class="slot-btn"
                hover-class="slot-btn__hover"
                hover-stay-time="150"
              >
                <view class="des">
                  <u-icon name="/static/xj.png" size="80"></u-icon>
                  <view class="des-text">添加照片</view>
                </view>
              </view>
            </u-upload>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import { BASE_URL, UP_URL } from '@/common/config'

export default {
  name: 'push-upload',
  props: {},
  data() {
    return {
      action: BASE_URL + UP_URL,
      fileList: []
    }
  },
  methods: {
    onRemove(res) {
      console.log(res)
    },
    beforeUpload(index, list) {
      console.log(index, list)
    },
    //选择地址、修改编辑地址
    chooseAddressView(index) {
      uni.chooseLocation({
        success: (res) => {
          console.log('res', res)
          if (!res.name || !res.address || !res.latitude || !res.longitude) return
          // let addressObj = {
          // 	title: res.name,
          // 	address: res.address,
          // 	latitude: res.latitude,
          // 	longitude: res.longitude
          // }
          // console.log('addressObj', addressObj)
          this.form.latitude = res.latitude
          this.form.longitude = res.longitude
          this.form.countyCode = countyCode
          this.form.detailAddress = res.address
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
input {
  font-size: 30rpx;
  color: #333333;
}

.cell-right {
  margin-right: 100rpx;
}

.from {
  .custom_modules {
    padding-left: 20rpx;
  }

  .title {
    font-size: 30rpx;
    width: 240rpx;
    font-weight: 600;
  }
}

.upload-group {
  width: 100%;
  margin-top: 28rpx;

  .slot-btn {
    position: relative;
    width: 200rpx;
    height: 200rpx;
    background-position: center;
    background-size: cover;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    border-radius: 20rpx;

    .des {
      text-align: center;

      .des-text {
        font-size: 24rpx;
        color: #999999;
      }
    }
  }
}
</style>
